package main

import (
	"fmt"
	"github.com/spf13/viper"
	"os"
	"server/Logic"
	"server/logutil"
	"server/servers"
	"server/servers/diamondServer"
	"server/servers/resourceServer"
	"server/servers/userServer"
)

func main() {
	logutil.InitializeLogger("iewErr.log")
	InitConfig()
	servers.NewServiceContext(Logic.InitDB())
	go userServer.UserServer(viper.GetString("userServer.port"))
	go resourceServer.ResourceServer(viper.GetString("resourceServer.port"))
	go diamondServer.DiamondServer(viper.GetString("diamondServer.port"))
	select {}
}

func InitConfig() {

	workDir, _ := os.Getwd()                 //获取目录对应的路径
	viper.SetConfigName("config")            //配置文件名
	viper.SetConfigType("yml")               //配置文件类型
	viper.AddConfigPath(workDir + "/config") //执行单文件运行，
	fmt.Println("Added config path:", workDir+"/config")

	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}

}
